package com.emokili.ewa.app.service.impl;

import com.emokili.ewa.app.service.AccountSettingService;
import com.emokili.ewa.core.frame.entity.MemberEntity;
import com.emokili.ewa.core.frame.service.MemberService;
import com.emokili.ewa.core.frame.vo.AccountSettingVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountSettingServiceImpl implements AccountSettingService {
    @Autowired
    private MemberService memberService;

    @Override
    public AccountSettingVo findById(Long memberId) {
        AccountSettingVo accountSettingVo = new AccountSettingVo();
        MemberEntity memberEntity = memberService.getById(memberId);
        BeanUtils.copyProperties(memberEntity,accountSettingVo);
        accountSettingVo.setPassword(null);
        return accountSettingVo;
    }

    @Override
    public void update(AccountSettingVo accountSettingVo) {
        MemberEntity memberEntity = new MemberEntity();
        BeanUtils.copyProperties(accountSettingVo,memberEntity);
        memberService.saveOrUpdate(memberEntity);
    }

}
